package com.situ.studentmanagement;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * Created by niugao on 6/13/2016.
 */


@Component
@Aspect
public class TestAop {
//    @Pointcut("execution(* com.situ.studentmanagement.service.*.*(..))")
//    public void anyMethod() {
//    }

    @Before(value = "execution(* com.situ.studentmanagement.service.*.*(..))")
    public void doBefore(JoinPoint jp) {
        System.out.println("===========进入before advice============ \n");

        System.out.print("准备在" + jp.getTarget().getClass() + "对象上用");
        System.out.print(jp.getSignature().getName() + "方法进行对 '");

        System.out.println("要进入切入点方法了 \n");
    }

//    @AfterReturning(value = "anyMethod()", returning = "result")
//    public void doAfter(JoinPoint jp, String result) {
//        System.out.println("==========进入after advice=========== \n");
//        System.out.println("切入点方法执行完了 \n");
//
//        System.out.print(jp.getArgs()[0] + "在");
//        System.out.print(jp.getTarget().getClass() + "对象上被");
//        System.out.print(jp.getSignature().getName() + "方法删除了");
//        System.out.print("只留下：" + result + "\n\n");
//    }
}
